package com.jyy.prefabricated.utils;



import java.util.Random;


public class KeyUtil {


    /**
     * 生成唯一的主键
     * 格式： 时间+随机数
     * @return
     */
    public static synchronized String genUniqueKey(){
        Random random = new Random();
        Integer a = random.nextInt(90) + 100;
        return System.currentTimeMillis() + String.valueOf(a);
    }

    /**
     * 生成验证码
     * @return
     */
    public static String genUniqueCode(){
        Random random = new Random();
        Integer a = random.nextInt(99999)+100000 * random.nextInt(10);
        return  String.valueOf(a);
    }


    public static void main(String[] args) {
        System.out.println(genUniqueKey());
    }
}
